﻿// =================================================================== 
// 数据访问层(GDIT.DAL)
//====================================================================
// 文件：DLinkType.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：链接类型信息数据访问层
// ===================================================================
using GDIT.Model;
using DevExpress.Data.Filtering;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Pattern;

namespace GDIT.DAL
{
    public class DLinkType : ILinkType
    {

        private XpoHelper.Test<Mtb_LinkType> userOperation = null;

        /// <summary>
        /// 新增链接类型对象
        /// </summary>
        /// <param name="link">需要新增的链接类型对象</param>
        /// <returns>1：新增成功  0：新增失败</returns>
        public int InsertLinkInfo(Mtb_LinkType link)
        {
            return XpoHelper.SaveAdded(link);
        }

        /// <summary>
        /// 更新链接类型对象
        /// </summary>
        /// <param name="link">需要的链接类型对象</param>
        /// <returns>1：更新成功  0：更新失败</returns>
        public int UpdateLinkInfo(Mtb_LinkType link)
        {
            userOperation = new XpoHelper.Test<Mtb_LinkType>();
            XPCollection xp = userOperation.Operation("OID", link.OID);
            foreach (Mtb_LinkType b in xp)
            {
                b.LinkTypeName = link.LinkTypeName;
                return XpoHelper.SaveModified(b);
            }
            return 0;
        }

        /// <summary>
        /// 删除链接类型对象
        /// </summary>
        /// <param name="link">需要的链接类型对象</param>
        /// <returns>1：删除成功  0：删除失败</returns>
        public int DeleteLinkInfo(Mtb_LinkType link)
        {
            userOperation = new XpoHelper.Test<Mtb_LinkType>();
            return userOperation.Delete(link.OID);
        }

        /// <summary>
        /// 查询所有链接类型对象
        /// </summary>
        /// <returns>所有链接类型对象集合</returns>
        public XPCollection SelectAllLinkInfo()
        {
            userOperation = new XpoHelper.Test<Mtb_LinkType>();
            return userOperation.Operation();
        }

        /// <summary>
        /// 查询单一链接类型对象
        /// </summary>
        /// <param name="link">需要查询的链接类型对象条件</param>
        /// <returns>单一链接类型对象</returns>
        public Mtb_LinkType SelectLinkInfoByLink(Mtb_LinkType link)
        {
            Mtb_LinkType bulletin = null;
            userOperation = new XpoHelper.Test<Mtb_LinkType>();
            XPCollection xp = userOperation.Operation("OID", link.OID);
            foreach (Mtb_LinkType b in xp)
            {
                bulletin = b;
            }
            return bulletin;
        }
    }
}
